package core.command;

import java.util.ArrayList;
import core.Drawing;
import core.Stroke;
import core.UserContext;

public class DeleteStrokesCommand extends AbstractCommand {
	UserContext context;
	ArrayList<Stroke> selectedStrokesBefore;	
	
	public DeleteStrokesCommand(Drawing drawing, UserContext context) {
		super(drawing);
		this.context = context;
		this.selectedStrokesBefore = (ArrayList<Stroke>) context.getSelectedStrokes().clone();
	}

	@Override
	public void execute() {
		for (int i=0; i<this.selectedStrokesBefore.size(); i++)
		{
			this.drawing.removeStroke(selectedStrokesBefore.get(i));
		}
		context.setSelectedStrokes(new ArrayList<Stroke>() );
	}

	@Override
	public void undo() {
		for (int i=0; i<selectedStrokesBefore.size(); i++)
		{
			this.drawing.addStroke(selectedStrokesBefore.get(i));
		}
		context.setSelectedStrokes((ArrayList<Stroke>) selectedStrokesBefore.clone());
	}
}
